﻿#ifndef _PAGEFILE_H_
#define _PAGEFILE_H_

#ifdef _WIN32
#pragma comment(lib,"sqlite3.lib")
#endif

#include <map>
#include <list>
#include <string>
#include <vector>
//#include "../public/guid.h"
#include "sqlite/include/sqlite3.h"
#include <boost/threadpool.hpp>

typedef struct devinfo{
	std::string strdid;
	std::string strkey;
	std::string strhid;
}DEVINFO;

class CPagefile
{
private:
	CPagefile();
	
public:
	~CPagefile();
	static CPagefile& GetInstance();

	int Start();
	int Stop();
    bool GetNewDeviceInfo(const std::string hardwareid, std::string &deviceid, std::string &devicekey);
	int GetSendSnByHardid(const std::string deviceid);

public:
	int GetDeviceInfoByHid(const std::string hardwareid, std::string &deviceid, std::string &devicekey);
	int GetDeviceInfoByDid(const std::string deviceid, std::string &hardwareid, std::string &devicekey);
	int GetAllDeviceInfo(std::vector<DEVINFO> &vecdevinfo);
	int GetDeviceInfoOfHidIsNull(std::vector<DEVINFO> &vecdevinfo);
	int GetDeviceInfoOfHid(std::vector<DEVINFO> &vecdevinfo);

	int DelDeviceInfoByDid(const std::string deviceid);

	int AddDeviceInfo(const std::string deviceid, const std::string hardwareid, const std::string devicekey);
private:
	sqlite3* pagefile_db;
	boost::recursive_mutex _rmutex;
};
#endif
